# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=crosstool-ng
pkgver=1.25.0
pkgrel=0
pkgdesc="tool for building toolchains"
url="http://crosstool-ng.org/"
license="LGPL-2.1-or-later GPL-2.0-or-later CC-BY-SA-2.5"
arch="x86 x86_64 ppc64le"
depends="
	autoconf
	automake
	bash
	bison
	cvs
	file
	flex
	g++
	gawk
	gperf
	libtool
	make
	patch
	sed
	wget
	xz
	texinfo"
makedepends="ncurses-dev help2man xz gettext-dev"
subpackages="$pkgname-doc $pkgname-bash-completion"
source="http://crosstool-ng.org/download/crosstool-ng/crosstool-ng-$pkgver.tar.xz
	0001-sunrpc.diff"

build() {
	./configure --prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info
	make
}

package() {
	make DESTDIR="$pkgdir" install

	# bash completion
	mkdir -p "$pkgdir"/usr/share/bash-completion/completions/
	mv "$pkgdir"/usr/share/bash-completion/completions/ct-ng \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname

	# glibc patch
	for glibc in 2.28 2.29; do
		install -D -m 0644 "$srcdir"/0001-sunrpc.diff \
			"$pkgdir"/usr/share/crosstool-ng/packages/glibc/$glibc/0001-sunrpc.patch
	done
}

sha512sums="
e25b6fb577ce439592a889fe73bbde4109309e7fe154e7133fefaeb5522c97e3f96958941aa1bc86448fcecb6b4021ff793c595048f5ef8e5ecc75e9a48c0c45  crosstool-ng-1.25.0.tar.xz
4ef553b1e5295924e86c8457fac7ad128107f97c7ea247246f89a626937906f67f9a734aa77dc438680c2ac4d684f74819f8fde105459de4402dc7315fffa805  0001-sunrpc.diff
"
